/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ca.jerg.canvas;

import ca.jerg.data.ErgPoint;

import javax.swing.undo.*;
import java.util.Iterator;

/**
 *
 * @author dave
 */
public class EditZoom extends AbstractUndoableEdit
{
	public EditZoom( Canvas canvas, ErgPoint oldMin, ErgPoint oldMax,
			ErgPoint min, ErgPoint max )
	{
		this.canvas = canvas;
		
		this.oldMax = oldMax;
		this.oldMin = oldMin;
		this.max = max;
		this.min = min;
	}
	
	@Override
	public void undo() throws CannotUndoException
	{	
		canvas.setMin(oldMin);
		canvas.setMax(oldMax);
		
		canvas.repaint();
	}
	
	@Override
	public void redo() throws CannotRedoException
	{
		canvas.setMin(min);
		canvas.setMax(max);
		
		canvas.repaint();
	}
	
	@Override
	public boolean canUndo() 
	{
		return true;
	}

	@Override
	public boolean canRedo() 
	{
		return true;
	}

	@Override
	public String getPresentationName() 
	{
		return "Add";
	}
	
	private Canvas canvas;

	private ErgPoint min;
	private ErgPoint max;
	private ErgPoint oldMin;
	private ErgPoint oldMax;
}
